add some orientation flipping code to the "flipping" test.
authorMichael Natterer <mitch@imendio.com>
Thu, 19 Feb 2009 15:12:35 +0000 (15:12 +0000)
committerMichael Natterer <mitch@src.gnome.org>
Thu, 19 Feb 2009 15:12:35 +0000 (15:12 +0000)
2009-02-19  Michael Natterer  <mitch@imendio.com>

* tests/testgtk.c: add some orientation flipping code to the
"flipping" test.

svn path=/trunk/; revision=22376

ChangeLog
tests/testgtk.c

index 152d0c4573f6bb337ef4176f2122ff955f1f90a1..7c1be4f2ad8a6d0327d3f7fa7d8b56a1d72e2224 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2009-02-19  Michael Natterer  <mitch@imendio.com>
+
+       * tests/testgtk.c: add some orientation flipping code to the
+       "flipping" test.
+
 2009-02-19  Michael Natterer  <mitch@imendio.com>
 
        * gtk/gtkscalebutton.c: make the orientation flipping much simpler
index b5c11055c912401c7206dd3f94865eb81121bfb7..568bb1a54c11f724c284a6b6018e0bb59f034aba 100644 (file)
@@ -8282,6 +8282,40 @@ flipping_toggled_cb (GtkWidget *widget, gpointer data)
   gtk_widget_set_default_direction (new_direction);
 }
 
+static void
+orientable_toggle_orientation (GtkOrientable *orientable)
+{
+  GtkOrientation orientation;
+
+  orientation = gtk_orientable_get_orientation (orientable);
+  gtk_orientable_set_orientation (orientable,
+                                  orientation == GTK_ORIENTATION_HORIZONTAL ?
+                                  GTK_ORIENTATION_VERTICAL :
+                                  GTK_ORIENTATION_HORIZONTAL);
+
+  if (GTK_IS_CONTAINER (orientable))
+    {
+      GList *children;
+      GList *child;
+
+      children = gtk_container_get_children (GTK_CONTAINER (orientable));
+
+      for (child = children; child; child = child->next)
+        {
+          if (GTK_IS_ORIENTABLE (child->data))
+            orientable_toggle_orientation (child->data);
+        }
+
+      g_list_free (children);
+    }
+}
+
+void
+flipping_orientation_toggled_cb (GtkWidget *widget, gpointer data)
+{
+  orientable_toggle_orientation (GTK_ORIENTABLE (GTK_DIALOG (gtk_widget_get_toplevel (widget))->vbox));
+}
+
 static void
 set_direction_recurse (GtkWidget *widget,
                       gpointer   data)
@@ -8335,9 +8369,24 @@ create_flipping (GtkWidget *widget)
       gtk_window_set_title (GTK_WINDOW (window), "Bidirectional Flipping");
 
       check_button = gtk_check_button_new_with_label ("Right-to-left global direction");
+      gtk_container_set_border_width (GTK_CONTAINER (check_button), 10);
+      gtk_box_pack_start (GTK_BOX (GTK_DIALOG (window)->vbox),
+                         check_button, TRUE, TRUE, 0);
+
+      if (gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL)
+       gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button), TRUE);
+
+      g_signal_connect (check_button, "toggled",
+                       G_CALLBACK (flipping_toggled_cb), NULL);
+
+      check_button = gtk_check_button_new_with_label ("Toggle orientation of all boxes");
+      gtk_container_set_border_width (GTK_CONTAINER (check_button), 10);
       gtk_box_pack_start (GTK_BOX (GTK_DIALOG (window)->vbox), 
                          check_button, TRUE, TRUE, 0);
 
+      g_signal_connect (check_button, "toggled",
+                       G_CALLBACK (flipping_orientation_toggled_cb), NULL);
+
       gtk_box_pack_start (GTK_BOX (GTK_DIALOG (window)->vbox), 
                          create_forward_back ("Default", GTK_TEXT_DIR_NONE),
                          TRUE, TRUE, 0);
@@ -8350,14 +8399,6 @@ create_flipping (GtkWidget *widget)
                          create_forward_back ("Right-to-Left", GTK_TEXT_DIR_RTL),
                          TRUE, TRUE, 0);
 
-      if (gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL)
-       gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button), TRUE);
-
-      g_signal_connect (check_button, "toggled",
-                       G_CALLBACK (flipping_toggled_cb), NULL);
-
-      gtk_container_set_border_width (GTK_CONTAINER (check_button), 10);
-      
       button = gtk_button_new_with_label ("Close");
       g_signal_connect_swapped (button, "clicked",
                                G_CALLBACK (gtk_widget_destroy), window);